package com.bawei.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bawei.model.Provider;
import com.bawei.service.ProviderService;
import com.bawei.util.JsonUtil;

@RestController
@CrossOrigin(origins="*")
@RequestMapping("/provider/")
public class ProviderController {
	@Autowired
	private ProviderService providerService;
	
	@RequestMapping("getProvider")
	public String getProvider() {
		return JsonUtil.success(providerService.getProvider());
	}	
	
	@RequestMapping("getProviderById")
	public String getProviderById(String id) {
		return JsonUtil.success(providerService.getProviderById(Long.valueOf(id)));
	}
	
	@RequestMapping("addProvider")
	public String addProvider(Provider provider) {
		providerService.addProvider(provider);
		return JsonUtil.success();
	}
	
	@RequestMapping("delProvider")
	public String delProvider(String id) {
		providerService.delProvider(Long.valueOf(id));
		return JsonUtil.success();
	}
	
	@RequestMapping("updateProvider")
	public String updateProvider(Provider provider,String gStatus,String id) {
		System.out.println(provider);
		System.out.println(gStatus);
		System.out.println(id);
		providerService.updateProvider(provider);
		return JsonUtil.success();
	}
	//getProviderByCondition5689
	@RequestMapping("getProviderByCondition")
	public String getProviderByCondition(Provider provider) {
		return JsonUtil.success(providerService.getProviderByCondition(provider));
	}
	
	@RequestMapping("updateStatus")
	public String updateStatus(Provider provider) {
		providerService.updateStatus(provider);
		return JsonUtil.success();
	}
	@RequestMapping("updateStatusNo")
	public String updateStatusNo(Provider provider) {
		providerService.updateStatusNo(provider);
		return JsonUtil.success();
	}
	
}
